<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>资产日志</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="../css/base.css">
  <link rel="stylesheet" href="../js/layer/layui-v2.3.0/layui/css/layui.css">
  <style>
    body{
      overflow: auto;
    }
    /* 资产入库弹出层 */
    #zcrkModal{
      background: #fff;
      padding: 15px 100px;
    }
    .modal-input-half{
      display: inline-block;
      width: 48%;
    }
    .layui-input-block .modal-input-half:last-child{
      float: right;
    }
    #zcrkModal .modal-btn-label{
      font-size: 12px;
      color: #d50014;
    }
    #zcrkModal .addInputBox{
      margin-left: 110px;
      margin-bottom: 15px;
    }
    #zcrkModal .modal-btn{
      display: inline-block;
      vertical-align: middle;
      border:1px solid #d50014;
      color: #d50014;
      font-size: 18px;
      margin-left: 10px;
      cursor: pointer;
      /* border-radius: 50%; */
      width: 20px;
      height: 20px;
      text-align: center;
      line-height: 18px;
    }
    #zcrkModal .upload-content{
      height: 82px;
      line-height: 82px;
      font-size: 16px;
      color: #7e7e7e;
      text-align: center;
      border: 1px solid #D2D2D2;
    }
  </style>
</head>
<body>
  <div id="zcrkModal">
    <form class="layui-form" action="">
      <div class="layui-form-item">
        <label class="layui-form-label">资产名称</label>
        <div class="layui-input-block">
          <input type="text" name="title" required  lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">资产类型</label>
        <div class="layui-input-block">
          <select name="city" lay-verify="required">
            <option value=""></option>
            <option value="0">类型1</option>
            <option value="1">类型2</option>
            <option value="2">类型3</option>
            <option value="3">类型4</option>
            <option value="4">类型5</option>
          </select>
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">资产类别</label>
        <div class="layui-input-block">
          <select name="city" lay-verify="required">
            <option value=""></option>
            <option value="0">类别1</option>
            <option value="1">类别2</option>
            <option value="2">类别3</option>
            <option value="3">类别4</option>
            <option value="4">类别5</option>
          </select>
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">资产型号</label>
        <div class="layui-input-block">
          <input type="text" name="title" required  lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">放置地点</label>
        <div class="layui-input-block">
          <input type="text" name="title" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">采购时间</label>
        <div class="layui-input-block">
          <input type="text" name="title" required  lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">采购价格</label>
        <div class="layui-input-block">
          <input type="text" name="title" required  lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">管理人员</label>
        <div class="layui-input-block">
          <input type="text" name="title" required  lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
        </div>
      </div>

      <div class="free-item-box">
        <div class="layui-form-item">
          <label class="layui-form-label">自由属性</label>
          <div class="layui-input-block">
            <input type="text" name="title" required  lay-verify="required" placeholder="" autocomplete="off" class="layui-input modal-input-half">
            <input type="text" name="title" required  lay-verify="required" placeholder="" autocomplete="off" class="layui-input modal-input-half">
          </div>
        </div>
      </div>
      
      <div class="addInputBox">
        <span class="modal-btn-label">可添加属性</span>
        <i class="layui-icon modal-btn add-hook">+</i>
        <i style="display: none" class="layui-icon modal-btn sub-hook">-</i>
      </div>
      <!-- <div class="addInputBox">
        <div class="upload-content">请添加产品图片</div>
      </div> -->
      <div class="layui-form-item">
          <label class="layui-form-label">产品图片</label>
          <div class="layui-input-block">
              <button type="button" class="layui-btn layui-btn-normal" id="uploadBtn">
                <i class="layui-icon">&#xe67c;</i>上传图片
              </button>
          </div>
        </div>
      <div class="layui-form-item">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
          <input type="text" name="title" required  lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
        </div>
      </div>
    </form>
  </div>
  <script src="../js/jquery/jquery.min.js"></script>
  <script src="../js/layer/layui-v2.3.0/layui/layui.all.js"></script>
  <script>
    layui.use('upload', function(){
      var upload = layui.upload;
      
      //执行实例
      var uploadInst = upload.render({
        elem: '#test1' //绑定元素
        ,url: '/upload/' //上传接口
        ,done: function(res){
          //上传完毕回调
        }
        ,error: function(){
          //请求异常回调
        }
      });
    });

    var freeCount = 0;
    // 自由属性添加事件
    $('.add-hook').on('click', function () {
      freeCount++;
      // 显示删除按钮
      if (freeCount == 1) {
        $('.sub-hook').css('display', 'inline-block');
      }
      $('.free-item-box').append(
        '<div class="layui-form-item">'+
          '<div class="layui-input-block">'+
            '<input type="text" name="title" required  lay-verify="required" placeholder="" autocomplete="off" class="layui-input modal-input-half">'+
            '<input type="text" name="title" required  lay-verify="required" placeholder="" autocomplete="off" class="layui-input modal-input-half">'+
          '</div>'+
        '</div>')
    })
    // 自由属性删除事件
    $('.sub-hook').on('click', function () {
      if (freeCount == 0) return;
      var delElm = $('.free-item-box .layui-form-item')[freeCount];
      // 删除元素
      $(delElm).remove();
      freeCount--;
      if (freeCount == 0) {
        $(this).css('display', 'none');
      }
    })
  </script>
</body>
</html>